﻿using System;
using System.Collections.Generic;
using Autodesk.Revit.DB;

namespace YArchitech.HVAC.AuxiliaryCurve
{
	public class AngleNumberPointsGet : AuxiliaryPointsGet
	{
		public AngleNumberPointsGet(XYZ minArgu, XYZ maxArgu, XYZ anglePtArgu, int xNumberArgu, int yNumberArgu, ref Dictionary<XYZ, XYZ> dicxArgu, ref Dictionary<XYZ, XYZ> dicYArgu) : base(ref dicxArgu, ref dicYArgu)
		{
			this.min = minArgu;
			this.max = maxArgu;
			this.anglePt = anglePtArgu;
			this.xNumber = xNumberArgu;
			this.yNumber = yNumberArgu;
		}

		public override bool GetPoints()
		{
			double num = this.min.DistanceTo(this.max);
			double num2 = this.anglePt.DistanceTo(this.max);
			XYZ xyz = (this.max - this.min).Normalize();
			XYZ xyz2 = (this.anglePt - this.max).Normalize();
			double num3;
			if (this.xNumber == 1)
			{
				num3 = num2;
			}
			else
			{
				num3 = num2 / (double)(this.xNumber - 1);
			}
			double num4;
			if (this.yNumber == 1)
			{
				num4 = num;
			}
			else
			{
				num4 = num / (double)(this.yNumber - 1);
			}
			XYZ key = new XYZ(0.0, 0.0, 0.0);
			XYZ value = new XYZ(0.0, 0.0, 0.0);
			double num5 = 0.0;
			double num6 = 0.0;
			if (num4 > 0.0)
			{
				for (int i = 0; i < this.yNumber; i++)
				{
					key = this.min + num5 * xyz;
					value = this.min + num5 * xyz + num2 * xyz2;
					this.dicY.Add(key, value);
					num5 += num4;
				}
			}
			if (num3 > 0.0)
			{
				for (int j = 0; j < this.xNumber; j++)
				{
					key = this.min + num6 * xyz2;
					value = this.max + num6 * xyz2;
					this.dicX.Add(key, value);
					num6 += num3;
				}
			}
			return true;
		}

		protected XYZ min;

		protected XYZ max;

		protected XYZ anglePt;

		protected int xNumber;

		protected int yNumber;
	}
}
